/** CS2340 Spring 2011 Project
 *  Team: 40 Jiggawatt Hard Driver
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 *
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */

// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString
package edu.gatech.jiggawatt.office.model;

import java.io.Serializable;

/**
 * Represents Appointment
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */
public class Appointment implements Comparable<Appointment>, Serializable // $codepro.audit.disable declareDefaultConstructors
{	
	private String id;	
	private Date date;
	private Time time;	
	private String desiredDoctor;
	private String reason;
	
	/**
	 * Creates appointment
	 * @param id id of patient
	 * @param date date of appointment
	 * @param time time of appointment
	 * @param desiredDoctor desirerd doctor
	 * @param reason reasong of appointment
	 */
	public Appointment(String id, Date date, Time time, String desiredDoctor, String reason)
	{
		this.id = id;
		this.date = date;
		this.time = time;
		this.desiredDoctor = desiredDoctor;
		this.reason = reason;
	}
	
	/**
	 * returns date
	 * @return date
	 */
	public Date getDate()
	{
		return date;
	}

	/**
	 * returns time
	 * @return time
	 */
	public Time getTime()
	{
		return time;
	}
	
	/**
	 * returns year
	 * @return year
	 */
	public int getYear()
	{
		return date.getYear();
	}
	
	/**
	 * returns month
	 * @return month
	 */
	public int getMonth()
	{
		return date.getMonth();
	}
	
	/**
	 * returns day
	 * @return day
	 */
	public int getDay()
	{
		return date.getDay();
	}
	
	/**
	 * returns desired doctor
	 * @return desired doctor
	 */
	public String getDesiredDoctor()
	{
		return desiredDoctor;
	}
	
	/**
	 * returns reason
	 * @return reason
	 */
	public String getReason()
	{
		return reason;
	}
	
	/**
	 * sets the date
	 * @param date date to set
	 */
	public void setDate(Date date)
	{
		this.date = date;
	}
	
	/**
	 * sets the time
	 * @param time time to set
	 */
	public void setTime(Time time)
	{
		this.time = time;
	}
	
	/**
	 * sets desired doctor
	 * @param desiredDoctor desired doctor to set
	 */
	public void setDesiredDoctor(String desiredDoctor)
	{
		this.desiredDoctor = desiredDoctor;
	}
	
	/**
	 * sets reason
	 * @param reason reason to set
	 */
	public void setReason(String reason)
	{
		this.reason = reason;
	}
	
	/**
	 * gets id
	 * @return id
	 */
	public String getId()
	{
		return id;
	}
	
	/**
	 * returns string format of appointment
	 * @return string format of appointment
	 */
	public String toString()
	{
		return date + " " + time;
	}
	
	/**
	 * compares this appointment to the other
	 * @param app other app to compare
	 * @return 0 if equals, 1 if this one is later, -1 if this one precedes
	 */
	public int compareTo(Appointment app) 
	{
		int dateCompare = date.compareTo(app.getDate());
        
		if (0 == dateCompare)
		{
			return time.compareTo(app.getTime());
		}
		
        return dateCompare;
    }
	
	/**
	 * compares equality
	 * @param app other appointment to check equality
	 * @return true if equals, false otherwise
	 */
	public boolean equals(Appointment app) // $codepro.audit.disable checkTypeInEquals, com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.obeyEqualsContract.obeyGeneralContractOfEquals
	{
		return id.equals(app.getId()) && (0 == date.compareTo(app.getDate())) && (0 == time.compareTo(app.getTime()))
				&& desiredDoctor.equals(app.getDesiredDoctor()) && reason.equals(app.getReason());
	}

}